package com.wedimob.plugins;

import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import com.wedimob.common.Comment;
import com.wedimob.common.CommentType;
import com.wedimob.common.Rate;
import com.wedimob.common.User;

/**
 * All feedback about a plugin
 * 
 * @author melouadi
 * 
 */
public interface FeedbackPluginManager {
	/**
	 * Retreive rating for a given plugin Quality of service<br/>
	 * Rate = Avg(Rates)
	 * 
	 * @param plugins
	 *            target
	 * @return rates
	 */
	Map<SimplePlugin, Rate> rates(Set<SimplePlugin> plugins);

	/**
	 * Retreive popularity for a given plugin Nb of active installation<br/>
	 * When a plugin is installed +1<br/>
	 * When a plugin is removed -1<br/>
	 * Rate = NBInstallation / Max(NbInstallation)
	 * 
	 * @param plugins
	 *            target
	 * @return rates
	 */
	Map<SimplePlugin, Rate> popularities(Set<SimplePlugin> plugins);

	/**
	 * Retreive user comment about a plugin
	 * 
	 * @param plugins
	 *            target
	 * @param type
	 *            comment type
	 * @param local
	 *            language
	 * @return comment iterators
	 */
	Map<SimplePlugin, Iterator<Comment>> comments(Set<SimplePlugin> plugins,
			CommentType type, Locale local);

	/**
	 * Check if user can rate plugins
	 * 
	 * @param user
	 *            current user
	 * @param plugins
	 *            to rate
	 * @return true if user can rate the plugin
	 */
	Map<SimplePlugin, Boolean> rated(User user, Set<SimplePlugin> plugins);

	/**
	 * Give a rate for a given plugin
	 * 
	 * @param user
	 *            current user
	 * @param plugin
	 *            to rate
	 * @param rate
	 *            from 0 to 5
	 */
	void rate(User user, SimplePlugin plugin, Rate rate);

	/**
	 * Give a comment for a given plugin
	 * 
	 * @param user
	 *            current user
	 * @param plugin
	 *            to comment
	 * @param comment
	 *            definition
	 */
	void comment(User user, SimplePlugin plugin, Comment comment);

}
